package br.edu.ifrn.potigol.lang.nodes;

import br.edu.ifrn.potigol.lang.Context;
import br.edu.ifrn.potigol.lang.PotigolException;
import br.edu.ifrn.potigol.lang.PotigolObject;
import br.edu.ifrn.potigol.lang.PotigolRuntime;

public class ArrayAssignValueNode extends Node {
	private String name;
	private int index;
	private Node expression;
	
	public ArrayAssignValueNode(String name, int index, Node expression) {
		this.name = name;
		this.index = index;
		this.expression = expression;
	}

	@Override
	public PotigolObject eval(Context context) throws PotigolException {
		PotigolObject value = expression.eval(context);
	    context.setArrayValue(name, index, value);
	    return PotigolRuntime.getNil();
	}
}